package net.minecraft.src;

import java.util.Map;
import java.util.Random;
import java.io.*;

public class mod_pph extends BaseMod
{

    public mod_pph()
    {
  DimensionAPI.registerDimension(new WorldProviderPrePrehistoric());
  registerBlocks();
  registerNames();
  registerSprites();
  registerCraftingAndSmelting();
  registerEntities();
  registerAchievements();
  renderBlockAlgae = ModLoader.getUniqueBlockModelID(this, false);
  renderBlockPlant = ModLoader.getUniqueBlockModelID(this, false);
    }
 
 public static void AddTextureFX(TextureFX texturefx)
 {
  System.out.println("Adding TextureFX " + texturefx.getClass().getName());
  ModLoader.getMinecraftInstance().renderEngine.registerTextureFX(texturefx);
 }

 public static void SpawnParticle(EntityFX particle)
 {
  ModLoader.getMinecraftInstance().effectRenderer.addEffect(particle);
 }
 
 private void registerEntities()
 {
  ModLoader.RegisterEntityID(EntityAmmonite.class, "Ammonite", 110);
  ModLoader.RegisterEntityID(EntityBrachiopod.class, "Brachiopod", 111);
  ModLoader.RegisterEntityID(EntityDendrerpeton.class, "Dendrerpeton", 112);
  ModLoader.RegisterEntityID(EntityDragonfly.class, "Dragonfly", 113);
  ModLoader.RegisterEntityID(EntityMesothelae.class, "Mesothelae", 114);
  ModLoader.RegisterEntityID(EntitySwampMonster.class, "SwampMonster", 115);
  ModLoader.RegisterEntityID(EntityTrilobite.class, "Trilobite", 116);
 }
 
 public void AddRenderer(Map map)
 {
  map.put(EntityAmmonite.class, new RenderAmmonite(0.0F));
  map.put(EntityBrachiopod.class, new RenderBrachiopod(new ModelBrachiopod(), 0.0F));
  map.put(EntityDendrerpeton.class, new RenderDendrerpeton(new ModelDendrerpeton(), 0.0F));
  map.put(EntityDragonfly.class, new RenderDragonfly(new ModelDragonfly(), 0.5F));
  map.put(EntityMesothelae.class, new RenderMesothelae(-0.5F));
  map.put(EntitySwampMonster.class, new RenderSwampMonster(0.0F));
  map.put(EntityTrilobite.class, new RenderTrilobite(0.0F));
 }

 private void registerBlocks()
 {
  ModLoader.RegisterBlock(timeBox);
  ModLoader.RegisterBlock(portalBlock);
  ModLoader.RegisterBlock(algae, net.minecraft.src.ItemBlockAlgae.class);
  ModLoader.RegisterBlock(prehistoricSpawner);
  ModLoader.RegisterTileEntity(net.minecraft.src.TileEntityPrehistoricSpawner.class, "PrehistoricSpawner");
  ModLoader.RegisterBlock(prehistoricDirt);
  ModLoader.RegisterBlock(prehistoricWood, net.minecraft.src.ItemBlockPrehistoricWood.class);
  ModLoader.RegisterBlock(prehistoricLeaves, net.minecraft.src.ItemBlockPrehistoricLeaves.class);
  ModLoader.RegisterBlock(prehistoricLimestone); 
  ModLoader.RegisterBlock(PrehistoricLimestoneBrick);
  ModLoader.RegisterBlock(PrehistoricLimestoneSlab);
  ModLoader.RegisterBlock(PrehistoricLimestoneStairs);
  ModLoader.RegisterBlock(PrehistoricLimestoneSmooth);
  ModLoader.RegisterBlock(prehistoricGrass);
  ModLoader.RegisterBlock(prehistoricPlant, net.minecraft.src.ItemBlockPrehistoricPlant.class);
  ModLoader.RegisterBlock(grassTrap); 
  ModLoader.RegisterBlock(prehistoricVine);
  ModLoader.RegisterBlock(prehistoricSapling, net.minecraft.src.ItemBlockPrehistoricSapling.class);
  ModLoader.RegisterBlock(pyriteOre);
  ModLoader.RegisterBlock(charcarbon);
  ModLoader.RegisterBlock(grinder);
  ModLoader.RegisterTileEntity(TileEntityGrinder.class, "GrinderTile");
 }
 
 private void registerNames()
 {
  ModLoader.AddName(timeRod, "Time Rod");
  ModLoader.AddName(net, "Net");
  ModLoader.AddName(algaeItem, "Algae");
  ModLoader.AddName(ammoniteShell, "Ammonite Shell");
  ModLoader.AddName(brachiopodShell, "Brachiopod Shell");
  ModLoader.AddName(shellPowder, "Shell Powder");
  ModLoader.AddName(charcarbonItem, "Charcarbon");
  ModLoader.AddName(fang, "Fang");
  ModLoader.AddName(fangDagger, "Fang Dagger");
  ModLoader.AddName(dragonflyEggs, "Dragonfly Eggs");
  ModLoader.AddName(dragonflyItem, "Dragonfly");
  ModLoader.AddName(dragonflyCooked, "Cooked Dragonfly");
  ModLoader.AddName(dragonflyWing, "Dragonfly Wing");
  ModLoader.AddName(dragonflyEggsCooked, "Cooked Dragonfly Eggs");
  ModLoader.AddName(ironNugget, "Iron Nugget");
  ModLoader.AddName(amphibianMeat, "Amphibian Meat");
  ModLoader.AddName(amphibianMeatCooked, "Cooked Amphibian Meat");
  ModLoader.AddName(AmphibianBurger, "Amphibian Burger");
  ModLoader.AddName(pyriteCrystal, "Pyrite");
  ModLoader.AddName(sulfur, "Sulfur");
  ModLoader.AddName(timeBox, "Time Box");
  ModLoader.AddName(portalBlock, "Prehistoric Portal");
  ModLoader.AddName(new ItemStack(algae, 1, 0), "Algae");
  ModLoader.AddName(new ItemStack(algae, 1, 1), "Algae");
  ModLoader.AddName(new ItemStack(algae, 1, 2), "Dragonfly Eggs");
  ModLoader.AddName(new ItemStack(algae, 1, 3), "Gloop");
  ModLoader.AddName(prehistoricSpawner, "Carboniferous Monster Spawner");
  ModLoader.AddName(prehistoricDirt, "Carboniferous Soil");
  ModLoader.AddName(new ItemStack(prehistoricWood, 1, 0), "Carboniferous Log");
  ModLoader.AddName(new ItemStack(prehistoricWood, 1, 1), "Carboniferous Log");
  ModLoader.AddName(new ItemStack(prehistoricWood, 1, 2), "Carboniferous Log");
  ModLoader.AddName(new ItemStack(prehistoricWood, 1, 3), "Carboniferous Log");
  ModLoader.AddName(new ItemStack(prehistoricLeaves, 1, 0), "Carboniferous Leaves");
  ModLoader.AddName(new ItemStack(prehistoricLeaves, 1, 1), "Carboniferous Leaves");
  ModLoader.AddName(new ItemStack(prehistoricLeaves, 1, 2), "Carboniferous Leaves");
  ModLoader.AddName(prehistoricLimestone, "Carboniferous Limestone");
  ModLoader.AddName(PrehistoricLimestoneBrick, "Limestone Brick");
  ModLoader.AddName(PrehistoricLimestoneSlab, "Limestone Slab");
  ModLoader.AddName(PrehistoricLimestoneStairs, "Limestone Stairs");
  ModLoader.AddName(PrehistoricLimestoneSmooth, "Smooth Limestone");
  ModLoader.AddName(prehistoricGrass, "Carboniferous Grass");
  ModLoader.AddName(new ItemStack(prehistoricPlant, 1, 0), "Dead Shrub");
  ModLoader.AddName(new ItemStack(prehistoricPlant, 1, 1), "Tall Grass");
  ModLoader.AddName(new ItemStack(prehistoricPlant, 1, 2), "Fern");
  ModLoader.AddName(new ItemStack(prehistoricSapling, 1, 0), "Lepidodendron Sapling");
  ModLoader.AddName(new ItemStack(prehistoricSapling, 1, 1), "Calamites Sapling");
  ModLoader.AddName(new ItemStack(prehistoricSapling, 1, 2), "Cordaites Sapling");
  ModLoader.AddName(grassTrap, "Grass Trap");
  ModLoader.AddName(prehistoricVine, "Carboniferous Vine");
  ModLoader.AddName(pyriteOre, "Pyrite Ore");
  ModLoader.AddName(charcarbon, "Charcarbon");
  ModLoader.AddName(grinder, "Grinder");
 }
 
 private void registerSprites()
 {
  timeRod.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/timerod.png");
  net.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/net.png");
  algaeItem.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/algaeItem.png");
  ammoniteShell.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/ammoniteShell.png");
  brachiopodShell.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/brachiopodShell.png");
  shellPowder.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/shellPowder.png");
  fang.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/fang.png");
  fangDagger.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/fangDagger.png");
  dragonflyEggs.iconIndex = dragonflyEggsCooked.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/eggs.png");
  dragonflyItem.iconIndex = dragonflyCooked.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/dragonflyItem.png");
  dragonflyWing.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/wing.png");
  ironNugget.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/ironNugget.png");
  amphibianMeat.iconIndex = amphibianMeatCooked.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/amphibianMeat.png");
  AmphibianBurger.iconIndex = AmphibianBurger.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/amphibianBurger.png");
  pyriteCrystal.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/pyriteCrystal.png");
  sulfur.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/sulfur.png");
  timeBox.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/timebox0.png");
  portalBlock.blockIndexInTexture = ModLoader.getUniqueSpriteIndex("/terrain.png");
  AddTextureFX(new TexturePPHPortalFX());
  algae.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/algae.png");
  prehistoricSpawner.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/spawner.png");
  prehistoricDirt.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/dirt.png");
  prehistoricWood.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/wood.png");
  prehistoricLimestone.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/limestone.png");
  prehistoricGrass.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/grassside.png");
  grassTrap.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/grasstop.png");
  prehistoricVine.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/vine.png");
  prehistoricSapling.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/lepidodendronSapling.png");
  pyriteOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/pyrite.png");
  charcarbon.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/charcarbon.png");
  grinder.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/grinderSide.png");
  ((BlockGrinder) grinder).blockIndexInTextureFront = ModLoader.addOverride("/terrain.png", "/pph/grinderFront.png");
  PrehistoricLimestoneBrick.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/limestoneBrick.png");
  PrehistoricLimestoneSlab.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "pph/limestonebrickSl.png");
  PrehistoricLimestoneStairs.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "pph/limestonebrickSt.png");
  PrehistoricLimestoneSmooth.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/limestoneCooked.png");
 }
 
 private void registerCraftingAndSmelting()
 {
  ModLoader.AddRecipe(new ItemStack(timeRod, 1), new Object[] { "  d", " s ", "s  ", Character.valueOf('d'), Item.diamond, Character.valueOf('s'), Item.stick });
  ModLoader.AddRecipe(new ItemStack(timeBox, 1), new Object[] { "gig", "drd", "gig", Character.valueOf('g'), Item.lightStoneDust, Character.valueOf('i'), Item.ingotIron, Character.valueOf('d'), Item.diamond, Character.valueOf('r'), Block.torchRedstoneActive });
  ModLoader.AddRecipe(new ItemStack(Block.planks, 4), new Object[] { "x", Character.valueOf('x'), prehistoricWood });
  ModLoader.AddRecipe(new ItemStack(net, 1), new Object[] { " xx", " sx", " s ", Character.valueOf('x'), Item.silk, Character.valueOf('s'), Item.stick });
  ModLoader.AddRecipe(new ItemStack(fangDagger, 1), new Object[] { "X", "|", Character.valueOf('X'), fang, Character.valueOf('|'), Item.stick }); 
  ModLoader.AddRecipe(new ItemStack(Item.arrow, 4), new Object[] { "f", "s", "w", Character.valueOf('f'), Item.flint, Character.valueOf('s'), Item.stick, Character.valueOf('w'), dragonflyWing });
  ModLoader.AddRecipe(new ItemStack(Item.ingotIron, 1), new Object[] { "iii", "iii", "iii", Character.valueOf('i'), ironNugget }); 
  ModLoader.AddRecipe(new ItemStack(grinder, 1), new Object[] { "ccc", "s s", "csc", Character.valueOf('c'), Block.cobblestone, Character.valueOf('s'), Block.stone });
  ModLoader.AddShapelessRecipe(new ItemStack(Item.gunpowder, 1), new Object[] {sulfur, charcarbonItem});
  ModLoader.AddRecipe(new ItemStack(PrehistoricLimestoneBrick, 1), new Object[] { "dd ", "dd ", "   ", Character.valueOf('d'), PrehistoricLimestoneSmooth });
  ModLoader.AddRecipe(new ItemStack(PrehistoricLimestoneSlab, 2), new Object[] { "   ", "   ", "ddd", Character.valueOf ('d'), PrehistoricLimestoneSmooth});
  ModLoader.AddRecipe(new ItemStack(PrehistoricLimestoneStairs, 4), new Object[] { "D   ", "DD ", "DDD", Character.valueOf ('D'), PrehistoricLimestoneSmooth});
  ModLoader.AddRecipe(new ItemStack(PrehistoricLimestoneSmooth, 1), new Object[] { "d   ", "   ", "   ", Character.valueOf ('d'), Block.dirt});
  ModLoader.AddRecipe(new ItemStack(AmphibianBurger, 4), new Object[] { "   ", " C ", " B ", Character.valueOf ('B'), Item.bread, Character.valueOf ('C'), amphibianMeatCooked});
  
 // dont look at there 2 recipes... they were just for testing, will be removed on official releace
  ModLoader.AddRecipe(new ItemStack(AmphibianBurger, 4), new Object[] { "   ", "  D", "  D", Character.valueOf ('D'), Block.dirt});
  ModLoader.AddRecipe(new ItemStack(prehistoricLimestone, 1), new Object[] { "   ", " D ", "   ", Character.valueOf ('D'), Block.dirt});
  
  ModLoader.AddSmelting(dragonflyItem.shiftedIndex, new ItemStack(dragonflyCooked));
  ModLoader.AddSmelting(dragonflyEggs.shiftedIndex, new ItemStack(dragonflyEggsCooked));
  ModLoader.AddSmelting(pyriteOre.blockID, new ItemStack(ironNugget));
  ModLoader.AddSmelting(amphibianMeat.shiftedIndex, new ItemStack(amphibianMeatCooked));
  ModLoader.AddSmelting(prehistoricLimestone.blockID, new ItemStack(PrehistoricLimestoneSmooth));

 }
 
 public int AddFuel(int i, int j)
 {
  if(i == charcarbonItem.shiftedIndex)
        {
            return 2400;
        } else
  {
   return -1;
  }
 }
 
 public static final Block timeBox;
 public static final Block portalBlock;
 public static final Block algae;
 public static final Block prehistoricSpawner;
 public static final Block prehistoricDirt;
 public static final Block prehistoricWood;
 public static final Block prehistoricLimestone;
 public static final Block PrehistoricLimestoneBrick;
 public static final Block PrehistoricLimestoneSlab;
 public static final Block PrehistoricLimestoneStairs;
 public static final Block PrehistoricLimestoneSmooth;
 public static final Block prehistoricGrass;
 public static final Block prehistoricLeaves;
 public static final Block prehistoricPlant;
 public static final Block grassTrap;
 public static final Block prehistoricVine;
 public static final Block prehistoricSapling;
 public static final Block pyriteOre;
 public static final Block charcarbon;
 public static final Block grinder;
 public static final Item timeRod = new ItemTimeRod(getId("ItemTimeRod", 15000)).setItemName("Time Rod");
 public static final Item net = new ItemNet(getId("ItemNet", 15001)).setItemName("Net");
 public static final Item algaeItem = new ItemAlgae(getId("ItemAlgae", 15002), 0).setItemName("Algae");
 public static final Item ammoniteShell = new Item(getId("ItemAmmoniteShell", 15003)).setItemName("Ammonite Shell");
 public static final Item brachiopodShell = new Item(getId("ItemBrachiopodShell", 15004)).setItemName("Brachiopod Shell");
 public static final Item shellPowder = new ItemShellPowder(getId("ItemShellPowder", 15005)).setItemName("Shell Powder");
 public static final Item fang = new Item(getId("ItemFang", 15006)).setItemName("Fang");
 public static final Item fangDagger = new ItemPrehistoricDagger(getId("ItemFangDagger", 15007), EnumToolMaterialPPH.BONE).setItemName("Fang Dagger");
 public static final Item charcarbonItem = new ItemCharcarbon(getId("ItemCharcarbon", 15008)).setIconCoord(7, 0).setItemName("Charcarbon");
 public static final Item dragonflyEggs = new ItemAlgae(getId("ItemDragonflyEggs", 15009), 2).setItemName("Dragonfly Eggs");
 public static final Item dragonflyItem = new ItemDragonfly(getId("ItemDragonfly", 15010)).setItemName("Dragonfly");
 public static final Item dragonflyCooked = new ItemDragonflyCooked(getId("ItemDragonflyCooked", 15011), 6, 0.6F, false).setItemName("Cooked Dragonfly");
 public static final Item dragonflyWing = new Item(getId("ItemDragonflyWing", 15012)).setItemName("Dragonfly Wing");
 public static final Item dragonflyEggsCooked = new ItemDragonflyCooked(getId("ItemDragonflyEggsCooked", 15013), 3, 0.3F, false).setItemName("Cooked Dragonfly Eggs");
 public static final Item ironNugget = new Item(getId("ItemIronNugget", 15014)).setItemName("Iron Nugget");
 public static final Item amphibianMeat = new ItemFood(getId("ItemAmphibianMeat", 15015), 3, 0.3F, true).setItemName("Amphibian Meat");
 public static final Item amphibianMeatCooked = new ItemAmphibianMeatCooked(getId("ItemAmphibianMeatCooked", 15016), 8, 0.8F, true).setItemName("Cooked Amphibian Meat");
 public static final Item AmphibianBurger = new ItemAmphibianBurger(getId("ItemAmphibianBurger", 15019), 8, 0.8F, true).setItemName("Amphibian Burger");
 public static final Item pyriteCrystal = new Item(getId("ItemPyrite", 15017)).setItemName("Pyrite Crystal");
 public static final Item sulfur = new Item(getId("ItemSulfur", 15018)).setItemName("Sulfur");
 
 static
 {
 grinder = new BlockGrinder(getId("BlockGrinder", 150), 0).setHardness(2.0F).setResistance(5.0F).setBlockName("Grinder");
 portalBlock = new BlockPrehistoricPortal(getId("BlockPrehistoricPortal", 151), 30).setHardness(-1F).setStepSound(Block.soundGlassFootstep).setLightValue(0.75F).setBlockName("Carboniferous Portal");
 timeBox = new BlockTimeBox(getId("BlockTimeBox", 152), 0).setHardness(2.0F).setResistance(5.0F).setBlockName("Time Turner");
 algae = new BlockAlgae(getId("BlockAlgae", 153)).setHardness(-1F).setBlockName("Algae").setRequiresSelfNotify();
 prehistoricSpawner = new BlockPrehistoricSpawner(getId("BlockPrehistoricSpawner", 154), 0).setHardness(2.0F).setResistance(5F).setStepSound(Block.soundStoneFootstep).setBlockName("Prehistoric Spawner");  
 prehistoricWood = new BlockPrehistoricWood(getId("BlockPrehistoricWood", 155), 0).setHardness(1.0F).setResistance(2F).setStepSound(Block.soundWoodFootstep).setBlockName("Prehistoric Wood");
 prehistoricLimestone = new BlockPrehistoricLimestone(getId("BlockPrehistoricLimestone", 156), 0).setHardness(1.0F).setResistance(7.5F).setStepSound(Block.soundStoneFootstep).setBlockName("Prehistoric Limestone");  
 prehistoricDirt = new BlockPrehistoricDirt(getId("BlockPrehistoricDirt", 157), 0).setHardness(0.6F).setStepSound(Block.soundGravelFootstep).setBlockName("Prehistoric Dirt"); 
 prehistoricGrass = new BlockPrehistoricGrass(getId("BlockPrehistoricGrass", 158), 0).setHardness(0.8F).setStepSound(Block.soundGrassFootstep).setBlockName("Prehistoric Grass"); 
 prehistoricLeaves = new BlockPrehistoricLeaves(getId("BlockPrehistoricLeaves", 159), 52).setHardness(0.2F).setLightOpacity(1).setStepSound(Block.soundGrassFootstep).setBlockName("Prehistoric Leaves").setRequiresSelfNotify();
 prehistoricPlant = new BlockPrehistoricPlant(getId("BlockPrehistoricPlant", 160), 0).setHardness(0.0F).setStepSound(Block.soundGrassFootstep).setBlockName("Prehistoric Plant");
 grassTrap = new BlockGrassTrap(getId("BlockGrassTrap", 161), 0).setHardness(0.2F).setStepSound(Block.soundGrassFootstep).setBlockName("Grass Trap"); 
 prehistoricVine = (new BlockPrehistoricVine(getId("BlockPrehistoricVine", 162), 0)).setHardness(0.2F).setBlockName("Prehistoric Vine").setRequiresSelfNotify();
 prehistoricSapling = (new BlockPrehistoricSapling(getId("BlockPrehistoricSapling", 163), 0)).setHardness(0.0F).setStepSound(Block.soundGrassFootstep).setBlockName("Prehistoric Sapling").setRequiresSelfNotify();
 pyriteOre = new BlockPyriteOre(getId("BlockPyriteOre", 164), 0).setHardness(3F).setResistance(4.0F).setBlockName("Pyrite Ore");
 charcarbon = new BlockCharcarbon(getId("BlockCharcarbon", 165), 0).setHardness(2F).setResistance(1.0F).setBlockName("Charcarbon");
 PrehistoricLimestoneBrick = new BlockPrehistoricLimestoneBrick(getId("BlockPrehistoricLimestoneBrick", 166), 0).setHardness(1.0F).setResistance(7.5F).setBlockName("Limestone Brick").setStepSound(Block.soundStoneFootstep);
 PrehistoricLimestoneSlab = new BlockPrehistoricLimestoneSlab(getId("BlockPrehistoricLimestoneSlab", 167), 0).setHardness(1.0F).setResistance(7.5F).setBlockName("Limestone Slab").setStepSound(Block.soundStoneFootstep);
 PrehistoricLimestoneStairs = new BlockPrehistoricLimestoneStairs(getId("BlockPrehistoricLimestoneStairs", 168), 0).setHardness(1.0F).setResistance(7.5F).setBlockName("Limestone Stairs").setStepSound(Block.soundStoneFootstep);
 PrehistoricLimestoneSmooth = new BlockPrehistoricLimestoneSmooth(getId("BlockPrehistoricLimestoneSmooth", 169),0).setHardness(0.9F).setResistance(5.0F).setBlockName("Smooth Limestone").setStepSound(Block.soundStoneFootstep);
 }
 
 public static int getId(String string, int i)
 {
  File file = new File(ModLoader.getMinecraftInstance().getMinecraftDir(), "PrePrehistoric_Config.txt");
  try
  {
   FileInputStream fileInput = new FileInputStream(file);
   BufferedInputStream bufferedInput = new BufferedInputStream(fileInput);
   DataInputStream dataInput = new DataInputStream(bufferedInput);
   while(dataInput.available() != 0)
   {
    String[] lineText = dataInput.readLine().split("=");
    if(lineText.length < 2)
    {
     continue;
    }
    String name = lineText[0];
    String id = lineText[1];
    if(string.equals(name) && isIdValid(name, id))
    {
     System.out.println(name + "'s ID has been assigned to " + id + ".");
     return Integer.valueOf(id);
    }
   }
   fileInput.close();
   bufferedInput.close();
   dataInput.close();
  }
  catch(IOException exception)
  {
   System.out.println("Failed to read PPH config file!");
   exception.printStackTrace();
  }
  System.out.println("Setting default ID " + i + " for " + string + ".");
  writeToConfigFile(file, string, i);
  return i;
    }
 
 public static void writeToConfigFile(File file, String string, int i)
 {
  try
  {
   PrintWriter printWriter = new PrintWriter(new FileWriter(file, true));
   printWriter.println(string + "=" + i);
   printWriter.flush();
   printWriter.close();
  }
  catch(IOException exception) 
  {
   System.out.println("Failed to write to PPH config file!");
   exception.printStackTrace();
  }
 }
 
 private static boolean isIdValid(String s, String s1)
 {
  try 
  {
   Integer.parseInt(s1);
   return true;
  }
  catch(NumberFormatException exception) 
  {
   System.out.println("ID " + s1 + " assigned to " + s + " is not a valid number.");
   return false;
  }
 }
 
 public boolean RenderWorldBlock(RenderBlocks renderblocks, IBlockAccess iblockaccess, int i, int j, int k, Block block, int l)
 {
  if(l == renderBlockAlgae)
  {
   return renderBlockAlgae(renderblocks, iblockaccess, i, j, k, block, l); 
  }
  if(l == renderBlockPlant)
  {
   return renderBlockPlant(renderblocks, iblockaccess, i, j, k, block, l); 
  }
  return false;
 }
 
 public boolean renderBlockAlgae(RenderBlocks renderblocks, IBlockAccess iblockaccess, int i, int j, int k, Block block, int l)
 {
  Tessellator tessellator = Tessellator.instance;
  tessellator.setBrightness(block.getMixedBrightnessForBlock(iblockaccess, i, j, k));
  int l1 = iblockaccess.getBlockMetadata(i, j, k);
        int i1 = block.getBlockTextureFromSideAndMetadata(0, l1);
        float f = block.getBlockBrightness(iblockaccess, i, j, k);
        tessellator.setColorOpaque_F(f, f, f);
      
        int j1 = (i1 & 0xf) << 4;
        int k1 = i1 & 0xf0;

        double tax = ((float)j1 + 16F) / 256F;
        double tay = (float)k1 / 256F;
        double tbx = (float)j1 / 256F;
        double tby = ((float)k1 + 16F) / 256F;
  
  tessellator.addVertexWithUV(i + 1, j - .1, k, tax, tay);
        tessellator.addVertexWithUV(i + 1, j - .1, k + 1, tax, tby);
        tessellator.addVertexWithUV(i, j - .1, k + 1, tbx, tby);
        tessellator.addVertexWithUV(i, j - .1, k, tbx, tay);
        tessellator.addVertexWithUV(i, j - .1, k, tbx, tay);
        tessellator.addVertexWithUV(i, j - .1, k + 1, tbx, tby);
        tessellator.addVertexWithUV(i + 1, j - .1, k + 1, tax, tby);
        tessellator.addVertexWithUV(i + 1, j - .1, k, tax, tay);
  return true;
 }
 
 public boolean renderBlockPlant(RenderBlocks renderblocks, IBlockAccess iblockaccess, int i, int j, int k, Block block, int l)
    {
        Tessellator tessellator = Tessellator.instance;
        tessellator.setBrightness(block.getMixedBrightnessForBlock(iblockaccess, i, j, k));
        float f = 1.0F;
        int i1 = block.colorMultiplier(iblockaccess, i, j, k);
        float f1 = (float)(i1 >> 16 & 0xff) / 255F;
        float f2 = (float)(i1 >> 8 & 0xff) / 255F;
        float f3 = (float)(i1 & 0xff) / 255F;
        if(EntityRenderer.anaglyphEnable)
        {
            float f4 = (f1 * 30F + f2 * 59F + f3 * 11F) / 100F;
            float f5 = (f1 * 30F + f2 * 70F) / 100F;
            float f6 = (f1 * 30F + f3 * 70F) / 100F;
            f1 = f4;
            f2 = f5;
            f3 = f6;
        }
        tessellator.setColorOpaque_F(f * f1, f * f2, f * f3);
        double d = i;
        double d1 = j;
        double d2 = k;
        if(block == prehistoricPlant)
        {
            long l1 = (long)(i * 0x2fc20f) ^ (long)k * 0x6ebfff5L ^ (long)j;
            l1 = l1 * l1 * 0x285b825L + l1 * 11L;
            d += ((double)((float)(l1 >> 16 & 15L) / 15F) - 0.5D) * 0.5D;
            d1 += ((double)((float)(l1 >> 20 & 15L) / 15F) - 1.0D) * 0.20000000000000001D;
            d2 += ((double)((float)(l1 >> 24 & 15L) / 15F) - 0.5D) * 0.5D;
        }
        renderblocks.drawCrossedSquares(block, iblockaccess.getBlockMetadata(i, j, k), d, d1, d2);
        return true;
    }
 
 public void TakenFromFurnace(EntityPlayer entityplayer, ItemStack itemstack)
    {
        if(itemstack.itemID == dragonflyEggsCooked.shiftedIndex)
        {
            entityplayer.addStat(youmurderer, 1);
        }
    }

 private void registerAchievements()
 {
  ModLoader.AddAchievementDesc(youmurderer, "You murderer!", "Cook some dragonfly eggs.");
  ModLoader.AddAchievementDesc(enterdimension, "Before the dinosaurs!", "Travel to the Carboniferous.");
  ModLoader.AddAchievementDesc(spiderburrow, "Spiders' Lair", "Find a spider burrow.");
 }
 
 public static Achievement youmurderer = new Achievement(3450, "youmurderer", 10, 2, dragonflyEggsCooked, null).registerAchievement();
 public static Achievement enterdimension = new Achievement(3451, "enterdimension", 10, 1, timeBox, null).registerAchievement();
 public static Achievement spiderburrow = new Achievement(3452, "spiderburrow", 11, 1, Block.web, null).registerAchievement();
 
 public String getVersion()
    {
        return "PPH 1.1.1 for MC1.1.0";
    }
 
 public void load()
 {
 }

 public static int renderBlockAlgae;
 public static int renderBlockPlant;}
